package cn.biplam.front.template.main;

import cn.biplam.common.wrapper.ErrorMessage;
import cn.biplam.front.html.HtmlDiv;
import cn.biplam.front.html.HtmlForm;
import cn.biplam.front.html.base.HtmlWindow;
import cn.biplam.front.html.base.Const.Clear_Type;
import cn.biplam.front.html.base.Const.Float_Type;
import cn.biplam.front.html.base.Const.Length_Unit;
import cn.biplam.front.html.base.Const.Position_Mode;
import cn.biplam.front.html.base.Const.Window_Event;
import cn.biplam.front.template.base.Button;
import cn.biplam.front.template.base.Input;
import cn.biplam.front.template.base.Input.Input_Type;

public class LoginForm {
	
	private String sHomeUrl;
	
	/**
	 * 系统登录模版
	 * @param homeUrl 系统路径
	 * @return HtmlWindow
	 * @throws ErrorMessage 
	 */
	public HtmlWindow get(String homeUrl) throws ErrorMessage{
		this.sHomeUrl = homeUrl;
		return this.setInput();
	}
	
	private HtmlWindow setInput() throws ErrorMessage{
		HtmlDiv bg=new HtmlDiv();
		bg.setStyleWidth("100",Length_Unit.percent);
		bg.setStyleHeight("100", Length_Unit.percent);
		bg.setBackGroundImage(sHomeUrl+"/images/bg.gif");
		
		HtmlDiv div = new HtmlDiv("loginDiv");
		div.setBackGroundImage(sHomeUrl+"/images/login.gif");
		div.setStyleSize(667, 437);
		div.setPositionMode(Position_Mode.Absolute);
		
		HtmlForm form = new HtmlForm("loginForm");
		form.setTarget(this.sHomeUrl+"/LoginDo.bi");
		HtmlWindow login = new HtmlDiv("login","lg");
		form.put(login);
		
		login.put(new Input("用户名称：","userName",Input_Type.text).get());
		login.put(new Input("密码：","userPassword",Input_Type.password).get());

		HtmlWindow button=new Button("确定").get();
		button.setClear(Clear_Type.Left);
		button.setMarginLeft("22");
		button.setMarginTop("10");
		button.bind(Window_Event.OnClick, "loginForm.submit();");
		login.put(button);
		button=new Button("返回").get();
		button.setFloat(Float_Type.Right);
		button.setMarginRight("10");
		button.setMarginTop("10");
		login.put(button);

		login.bind("ir('login',"+(25*7+15)+","+(10*7+2)+","+(15*7+5)+");");
		
		div.put(form);
		div.bind("setCenter("+div.getID()+");");
		div.bind("window.onresize=function(){setCenter("+div.getID()+")};");
		
		bg.put(div);
		return bg;
	}
	
}
